<template>
	<view class="container">

		<view class="boxPanel flex-between" @click="accountCancel">
			<view class="name">账号注销</view>
			<view class="row-right" style="flex: 1;">
				<u-icon name="arrow-right" color="#788096" size="14"></u-icon>
			</view>
		</view>
		
		<view class="fixfooter2">
			<view class="boxPanel c-origin flex-center text-bold " @click="logout()">
				退出登录
			</view>
		</view>
		
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				
			}
		},
		methods: {
			logout() {
				var that = this;
				uni.showModal({
					title: '提示',
					content: '确认要退出登录？',
					success: function (res) {
						if (res.confirm) {
							console.log('用户点击确定');
							uni.removeStorageSync('userInfo');
							uni.removeStorageSync('token');
							that.$util.redirectTo('/pages/index/index')
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				});
			},
			accountCancel() {
				var that = this;
				uni.showModal({
					title: '提示',
					content: '确认要注销账号吗？注销后将无法恢复',
					success: function (res) {
						if (res.confirm) {
							that.$api.sendRequest({
								url: "/api/member/applyCancel", 
								data: {},
								success: res2 => {
									if (res2.code == 0) {
										uni.showToast({
											title: '账号已注销',
											icon: 'success'
										});
										uni.removeStorageSync('userInfo');
										uni.removeStorageSync('token');
										that.$util.redirectTo('/pages/index/index')
									} else {
										that.$util.showToast({ title: res2.message });
									}
								}
							});
						}
					}
				});
			},
		}
	}
</script>

<style lang="scss" scoped>
.fixfooter2 {
	position: fixed;
	bottom: 30rpx;
	right: 0;
	left: 0;
	width: 100%;
	z-index: 9;
}
.row-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  .avatar {
    width: 82rpx;
    height: 82rpx;
    border-radius: 50%;
  }
  .rightimg {
    width: 8rpx;
    height: 14rpx;
    margin-left: 20rpx;
  }
  .edit {
    width: 40rpx;
    height: 40rpx;
    margin-left: 20rpx;
  }
}
</style>
